home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / graphic / tweak16b.zip / REGEDIT.CPP < prev    next >
C/C++ Source or Header  |  1993-08-04  |  2KB  |  71 lines

  1. /*
  2.     RegEdit.HPP
  3.  
  4. */
  5.  
  6. #include <conio.h>
  7. #include "Screen.hpp"
  8. #include "RegEdit.HPP"
  9.  
  10.  
  11. RegisterEditor::RegisterEditor(istream &ins)
  12.     : RegisterTable(ins)
  13.     {
  14.     prevSel = select = 0;
  15.     }
  16.  
  17. void RegisterEditor::printCon(int r)
  18.     {
  19.     // This gotoxy divides the registers into two columns.
  20.     gotoxy(40*(r / editHeight) +1, r % editHeight +1);
  21.     // Optionally print the left cursor.
  22.     textattr(CURSOR_COLOR);
  23.     cprintf(r==select ? "\20" : " ");
  24.     // Then put out the meat.
  25.     reg[r].printCon();
  26.     // And possibly the right cursor.
  27.     textattr(CURSOR_COLOR);
  28.     cprintf(r==select ? "\21" : " ");
  29.     // This gotoxy just puts the hardware cursor where it won't distract you.
  30.     gotoxy(40*(r / editHeight)+38, r % editHeight +1);
  31.     }
  32.  
  33. void RegisterEditor::printAllCon()
  34.     {
  35.     for (int r = 0; r < registers; r++)
  36.         printCon(r);
  37.     }
  38.  
  39. int RegisterEditor::updateSelect()
  40.     {
  41.     if (select < 0)
  42.         select = registers - 1;
  43.     else
  44.         if (select >= registers)
  45.             select = 0;
  46.     if (prevSel != select)
  47.         {
  48.         printCon(prevSel);
  49.         prevSel = select;
  50.         }
  51.     printCon(select);
  52.     return select;
  53.     }
  54.  
  55.  
  56. // RegisterEditor::showBitMask() updates the bit pattern display with
  57. //    the value of selected register.  This is TWEAK specific.
  58.  
  59. void RegisterEditor::showBitMask()
  60.     {
  61.     gotoxy(42,editHeight-4);
  62.     textattr(BITHEADER_COLOR);
  63.     cprintf("Bit mask: 7 6 5 4 3 2 1 0");
  64.     gotoxy(51,editHeight-3);
  65.     textattr(BITPATTERN_COLOR);
  66.     unsigned char v = reg[select].getValue();
  67.     for (int e=7; e>=0; e--)
  68.         cprintf( v&(1<<e) ? " 1" : " 0");
  69.     }
  70.  
  71.